#include <stdio.h>
#include "config.h"
#include <libavutil/avutil.h>
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)                  \
    if (CONFIG_##LIBNAME) {                                             \
        const char *indent = flags & INDENT? "  " : "";                 \
        if (flags & SHOW_VERSION) {                                     \
            unsigned int version = libname##_version();                 \
            av_log(NULL, level,                                         \
                   "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n",            \
                   indent, #libname,                                    \
                   LIB##LIBNAME##_VERSION_MAJOR,                        \
                   LIB##LIBNAME##_VERSION_MINOR,                        \
                   LIB##LIBNAME##_VERSION_MICRO,                        \
                   AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\
                   AV_VERSION_MICRO(version));                          \
        }                                                               \
        if (flags & SHOW_CONFIG) {                                      \
            const char *cfg = libname##_configuration();                \
            if (strcmp(FFMPEG_CONFIGURATION, cfg)) {                    \
                if (!warned_cfg) {                                      \
                    av_log(NULL, level,                                 \
                            "%sWARNING: library configuration mismatch\n", \
                            indent);                                    \
                    warned_cfg = 1;                                     \
                }                                                       \
                av_log(NULL, level, "%s%-11s configuration: %s\n",      \
                        indent, #libname, cfg);                         \
            }                                                           \
        }                                                               \
    }                                                                   \
//该标记只是是否先打印2个空格, indent， 不重要
#define INDENT 1

// 下面2个宏定义才重要
//显示版本号标志，有该标志才会打印VERSION
#define SHOW_VERSION 2
//显示配置标志，有该标志才会打印configure
#define SHOW_CONFIG 4

//版本信息和配置信息从库函数中来
//库函数是avutil_version(), avutil_configuration()

//该标志只是为了不重复打印而设置， 不重要
static int warned_cfg = 0;

int main(void)
{
	int flags = 6; //控制到底打不打 version 和 configure
	// level 是 avlog 的level , 默认 <32 才会有打印输出.
	int level = 0;
	// 当config.h中定义的 FFMPEG_CONFIGURATION 宏与读到的配置不同时,才打印一次警告信息
    PRINT_LIB_INFO(avutil,     AVUTIL,     flags, level);
	return 0;
}
